package CI.aufgabe2.cip.mynodes;

import java.util.List;

import CI.aufgabe2.cip.SymbolTable;
import CI.aufgabe2.cip.base.AbstractDescr;

public class MyPrintNode extends MyAbstractNode{

	private MyAbstractNode expr;
	
    public MyPrintNode(MyAbstractNode expr) {
        this.expr = expr;
    }
    
    public AbstractDescr compile(SymbolTable sym){
    	expr.compile(sym);
    	List<MyIdNode> varList = sym.getVarFormalParameters();
    	if(expr instanceof MyIdNode || expr instanceof MyRecordSelectorNode || expr instanceof MyArraySelectorNode)
    		write("CONT, 1");
    	if(varList.contains(expr))
    		write("CONT, 1");
    	write("PRINT");
    	return null;
    }
    
	@Override
	public void print() {
		trace("PrintNode ");
		if (expr != null) expr.print();
		unindent();
	}

}
